from django.db import models
from django.contrib.auth.models import User

UPLOAD_ROOT = './'
THUMB_ROOT = 'thumb'

class Film(models.Model):
    creator = models.ForeignKey(User,related_name = "film_creator_set")
    holder = models.ForeignKey(User,related_name = "film_holder_set") # current holder
    drifting = models.BooleanField()    # drifting or hold by someone?
    title = models.CharField(max_length = 30)
    description = models.TextField(null = True)
    number = models.SmallIntegerField() # total number of the film 
    used_number = models.SmallIntegerField(default = 0) # number of film used
    developed = models.BooleanField(default = False)    # film developed?
    number_per_person = models.SmallIntegerField(default = 100) # the number of photos each person is allowed to take
    right = models.SmallIntegerField() # the viewing right 0-all people can see, 1-only participant can see
    drift_option = models.SmallIntegerField(default = 0) # 0-send to particular friend, 1-random
    drift_direction = models.CharField(max_length = 40,null = True) # drifing direction
    hold_days = models.SmallIntegerField(default = 100) # days allowed to hold the film

class Photo(models.Model):
    creator = models.ForeignKey(User)
    title = models.CharField(max_length = 40)
    description = models.TextField()
    image = models.ImageField(upload_to = UPLOAD_ROOT)
    thumb = models.ImageField(upload_to = THUMB_ROOT)
    date = models.DateTimeField(auto_now_add = True)
    flim = models.ForeignKey(Film)
